package file

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

// QueryRowByKeyword query rows by keyword
func QueryRowByKeyword(fileName, key string) []string {
	f, err := os.Open(fileName)
	if err != nil {
		fmt.Printf("QueryRowByKeyword err is %v\n", err)
	}
    defer f.Close()
	scanner := bufio.NewScanner(f)
	var ss []string
	for scanner.Scan() {
		if strings.Contains(scanner.Text(), key) {
			ss = append(ss, scanner.Text())
		}
	}
	return ss
}
